import os, shlex, subprocess

#subprocess.call

# The library files are contained in a subdirectory of BASEDIR specified by LIBDIR.

# The raw data (CEL) files are contained in a subdirectory of BASEDIR
# called CEL.

# The result files are written to the RESULTDIR directory

# Base directory
BASEDIR = "/data/snppy/Hapmap6.0/Geno"
# Subdirectory of the base directory where the CEL files are located
CELFILEDIR = "CEL"
# Subdirectory of the base directory for library files.
LIBDIR = "CD_GenomeWideSNP_6_rev3/Full/GenomeWideSNP_6/LibFiles"
# Subdirectory of BASEDIR where the result files are placed
RESULTDIR = "result"
# Path of apt-probeset-genotype executable
APT = "apt-probeset-genotype"

cmd = """
%(APT)s \
  -o %(BASEDIR)s/%(RESULTDIR)s/ \
  -c %(BASEDIR)s/%(LIBDIR)s/GenomeWideSNP_6.cdf \
  --set-gender-method cn-probe-chrXY-ratio \
  --chrX-probes %(BASEDIR)s/%(LIBDIR)s/GenomeWideSNP_6.chrXprobes \
  --chrY-probes %(BASEDIR)s/%(LIBDIR)s/GenomeWideSNP_6.chrYprobes \
  --special-snps %(BASEDIR)s/%(LIBDIR)s/GenomeWideSNP_6.specialSNPs \
  --read-models-birdseed %(BASEDIR)s/%(LIBDIR)s/GenomeWideSNP_6.birdseed-v2.models \
  -a birdseed-v2 %(BASEDIR)s/%(CELFILEDIR)s/*.CEL
"""%{'APT':APT, 'BASEDIR':BASEDIR, 'CELFILEDIR':CELFILEDIR, 'LIBDIR':LIBDIR, 'RESULTDIR':RESULTDIR}

#args = shlex.split(cmd)
#print args
#subprocess.Popen(args, shell=True)
#subprocess.call(args, shell=True)
#subprocess.call(args)

os.system(cmd)
